<%@ page language="java" import="control.database.*" pageEncoding="gb2312"%>
<%@ page language="java" import="java.util.*,control.database.*,java.sql.*"%>
<%

String operatorNo="";
String StrOperId="";
String operatorName="";
String subcenterNo="";
String branchNo="0";
String sCompanyName="";
String OperatorNo="";
String p_strwhere="";

String subCenterNo="";
String branchName="";
    subCenterNo=request.getParameter("txtsubCenterNo");
         String SubCenterNo_sql="select SubCenterNo from CQ_Cmn_Branch Where SubCenterNo='"+subCenterNo+"'";
		
		String sql = "insert into CQ_Cmn_Branch(BranchNo,BranchName,SubCenterNo) values ('0'";
		
		if((request.getParameter("txtbranchName")!=null)&&(request.getParameter("txtbranchName")!=""))
		{
	   		branchName=new String(request.getParameter("txtbranchName").toString().getBytes("ISO8859_1"));
	   		//branchName=request.getParameter("txtbranchName").toString();
	  		p_strwhere=p_strwhere+",'"+branchName+"',";
        }
                     
		if((request.getParameter("txtsubCenterNo")!=null)&&(request.getParameter("txtsubCenterNo")!=""))
		{
			System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
	      	subCenterNo=request.getParameter("txtsubCenterNo").toString();
	      	System.out.println(request.getParameter("txtsubCenterNo"));
               
            p_strwhere=p_strwhere+"'"+subCenterNo+"'";
            System.out.println(p_strwhere);
		}
     //sql=sql+p_strwhere+")";
	 System.out.println(sql);
	
try
{  
    // user.User_Add();
     System.out.println("2221331"); 
    System.out.println(sql);
   DataBase db = new DataBase();
			ResultSet rs = null;
			rs=db.executeQuery(SubCenterNo_sql);
			if(rs.next()){
		  //tiao cuo wu ye
		    response.sendRedirect("success_failse2.jsp?flag=0");
			}
			else
			{
			DataBase db2 = new DataBase();
			 sql=sql+p_strwhere+")";
			 
			db2.executeUpdate(sql);
			System.out.println(sql);
			db2.closeStmt();
			db2.closeConn();
System.out.println("00000");
response.sendRedirect("success_failse2.jsp?flag=1");
			}
			rs.close();
			db.closeStmt();
			db.closeConn();
			
			 
}
catch(Exception e)
{
	//response.sendRedirect("success_failse.jsp?flag=0");
	System.out.println(e.getMessage());
}
%>
			
			
		    
			
	


